﻿using System.Collections.Generic;

namespace QueryBuilder.Core.Query
{
    /// <summary>
    /// 
    /// </summary>
    public class Join
    {
        private IEnumerable<string> usings = new List<string>();

        /// <summary>
        /// Initializes a new instance of the <see cref="Join"/> class.
        /// </summary>
        /// <param name="joinType">Type of the join.</param>
        /// <param name="toTable">To table.</param>
        /// <param name="fromTable">From table.</param>
        public Join(string joinType, ITable toTable, ITable fromTable)
        {
            this.ToTable = toTable;
            this.FromTable = fromTable;
            this.JoinType = joinType;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Join"/> class.
        /// </summary>
        /// <param name="joinType">Type of the join.</param>
        /// <param name="toTable">To table.</param>
        /// <param name="fromTable">From table.</param>
        /// <param name="constraint">The constraint.</param>
        public Join(string joinType, ITable toTable, ITable fromTable, Constraint constraint)
        {
            this.JoinType = joinType;
            this.ToTable = toTable;
            this.FromTable = fromTable;
            this.Constraint = constraint;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Join"/> class.
        /// </summary>
        /// <param name="joinType">Type of the join.</param>
        /// <param name="toTable">To table.</param>
        /// <param name="fromTable">From table.</param>
        /// <param name="usings">The usings.</param>
        public Join(string joinType, ITable toTable, ITable fromTable, IEnumerable<string> usings)
        {
            this.JoinType = joinType;
            this.ToTable = toTable;
            this.FromTable = fromTable;
            this.usings = usings;
        }

        /// <summary>
        /// Gets the usings.
        /// </summary>
        /// <value>The usings.</value>
        public IEnumerable<string> Usings
        {
            get { return this.usings; }
        }

        /// <summary>
        /// Gets or sets the type of the join.
        /// </summary>
        /// <value>The type of the join.</value>
        public string JoinType { get; set; }

        /// <summary>
        /// Gets or sets the constraint.
        /// </summary>
        /// <value>The constraint.</value>
        public Constraint Constraint { get; set; }

        /// <summary>
        /// Gets or sets to table.
        /// </summary>
        /// <value>To table.</value>
        public ITable ToTable { get; set; }

        /// <summary>
        /// Gets or sets from table.
        /// </summary>
        /// <value>From table.</value>
        public ITable FromTable { get; set; }
    }
}